<!--编辑厅店-->
<div class="dialog_content">
	<form id="info_form" name="info_form" action="{:u('store/edit')}" method="post">
	<table width="100%" class="table_form">
		<tr> 
	      <th width="80">{:L('store_name')} :</th>
	      <td><input type="text" name="name" value="{$info.name}" id="J_name" class="input-text"></td>
	    </tr>
	    <tr> 
	      <th>亚信编码 :</th>
	      <td><input type="text" name="ctms" value="{$info.ctms}" id="ctms" class="input-text"></td>
	    </tr>
	    <tr>
	      <th>{:L('select_bc')} :</th>
	      <td>
                <select class="mr10 J_region_select" data-pid="0" data-uri="{:U('region/ajax_getchilds',array('type'=>'bc'))}" data-selected=""></select>
				<input type="hidden" id="J_region_id" name="regionId_bcId" />
                
          </td>
	    </tr>
        <php>
            list($info['positionX'],$info['positionY']) = explode(',',$info['gps']);
            
        </php>
	    <tr>
	    	<th>{:L('positionX')} :</th>
	    	<td><input type="text" name="positionX" value="{$info.positionX}" class="input-text" size="20"></td>
	    </tr>
	    <tr>
	    	<th>{:L('positionY')} :</th>
	    	<td><input type="text" name="positionY" value="{$info.positionY}" class="input-text" size="20"></td>
	    </tr> 
        <!--{/*       
	    <tr>
	      <th>{:L('isHaveTaste')} :</th>
	      <td>
                <label><input type="radio" name="isHaveTaste" value="1" <if condition="$info.isHaveTaste eq 1">checked="true" </if> > {:L('yes')}</label>&nbsp;&nbsp;
                <label><input type="radio" name="isHaveTaste" <if condition="$info.isHaveTaste eq 0">checked="true" </if> value="0"> {:L('no')}</label>                
	      </td>          
	    </tr>
	    <tr>
	      <th>{:L('store_channel')} :</th>
	      <td>
                <label><input type="radio" <if condition="$info.channel eq 1">checked="true" </if> name="channel" value="1" checked> {:L('store_channel1')}</label>&nbsp;&nbsp;
                <label><input type="radio" id="channel2"  <if condition="$info.channel eq 2">checked="true"</if>  name="channel" value="2"> {:L('store_channel2')}</label>                
	      </td>          
	    </tr> 
		*/}-->
        <tr id="select_customer" style="display: none;">
            <th>{:L('select_customer')} :</th>
            <td>
            <select name="customerId">
                <option value="0">{:L('please_select')}</option>
                <volist name="customerList" id="val">
                    <option value="{$key}"  <if condition="$info.customerId eq $key">selected="true"</if> >{$val}</option>
                </volist>
            </select>
            </td>
        </tr>        
   
        <tr>
            <th>{:L('store_address')}</th>
            <td><input type="text" name="address" value="{$info.address}" class="input-text"  size="30"></td>
        </tr> 
              
	</table>
    <input type="hidden" name="id" value="{$info.id}" />
	</form>
</div>
<script>
$(function(){
	$.formValidator.initConfig({formid:"info_form",autotip:true});
    
    var check_cmts_url = "{:U('store/check_cmts_url',array('id'=>$info['id']))}";
    $("#ctms").formValidator({ onshow:lang.please_input+"ctms", onfocus:lang.please_input+"ctms"}).inputValidator({ min:1, onerror:lang.please_input+"ctms"}).ajaxValidator({type:"get", url:check_cmts_url,  datatype:"html", async:'false', success:function(data){ if(data == "1"){return true;}else{return false;}}, onerror:lang.bc_name_exists, onwait:lang.connecting_please_wait}).defaultPassed();   

	$('#info_form').ajaxForm({success:complate,dataType:'json',beforeSubmit:beforeSubmit});
    function complate(result){
        if(result.status == 1){
            $.dialog.get(result.dialog).close();
            $.pinphp.tip({content:result.msg});
            window.location.reload();
        } else {
            $.pinphp.tip({content:result.msg, icon:'alert'});
        }
    }
    
      function beforeSubmit(){
        var J_region = $("#J_region_id").val();
        $flag = false;
        if(J_region){
            var region_arr = J_region.split('_');
            if(region_arr[0]!=undefined && region_arr[1]!=undefined){
                $flag = true;              
            }else{
                $.pinphp.tip({content:"请先选择好商圈", icon:'alert'});
                return false;
            }
        }      
        return $flag;
    }
    
    
    //取地区路径
    var region_id= "{$info['regionId']}";
    var bc_id = "{$info['bcId']}" ;
    var ajax_get_spid = "{:U('region/ajax_get_spid', array('id'=>$info['regionId']))}";
    $.ajax({url:ajax_get_spid,success:function(con){
       con = con+region_id+"_"+bc_id+'|'; 
       $('.J_region_select').attr('data-selected',con);
        //联动查询
	   $('.J_region_select').cate_select({field:"J_region_id",J_cate_select:"J_region_select"});       
    }});
    
    //社会渠道
    var val=$('input:radio[name="channel"]:checked').val();
    if(val==2){
        $("#select_customer").show();
    } 
    $("#channel1").click(function(){
        $("#select_customer").hide();
    });    
 
});
</script>